package q155_MinStack;

import java.util.Deque;
import java.util.LinkedList;

public class MinStack {
    Deque<Integer> stack;
    Deque<Integer> minRecord;

    public MinStack() {
        stack = new LinkedList<>();
        minRecord = new LinkedList<>();
        minRecord.push(Integer.MAX_VALUE);
    }

    public void push(int val) {
        stack.push(val);
        minRecord.push(Math.min(minRecord.peek(), val));

    }

    public void pop() {
        stack.pop();
        minRecord.pop();
    }

    public int top() {
        return stack.peek();
    }

    public int getMin() {
        return minRecord.peek();
    }
}
